$(function () {

    $(".usererror").hide()

    $(".login-from-table").submit(function (e) {
        e.preventDefault()
        let username = $(".name_input").val()
        let password = $(".pass_input").val()

        let params = {
            username,
            password
        }

        $.ajax({
            url: '/df_api/v1/login_validate',
            data: JSON.stringify(params),
            method: "POST",
			dataType: "json",
			success: function (response) {
                if (response.code === 0){
                    location.href = '/static/index.html'
                }else {
                    $(".usererror").text(response.msg)
                    $(".usererror").show()
                }
			}
        })

    })
})